package nr.co.mhgames.polyanim.interpolation;

/**
 * Smooth step interpolation: interpolates using a cubic curve.
 * <p>
 * When B is some value, and A a value between [0, B]: <b>Result = (A / B)^2 *
 * (3 - 2 * (A / B))</b>
 * 
 * @author Mika Halttunen
 */
public final class SmoothStepInterpolator implements Interpolator {
	/**
	 * Static instance, use this to avoid allocating new instances. Provided for
	 * convenience.
	 */
	public static final SmoothStepInterpolator instance = new SmoothStepInterpolator();

	/**
	 * Interpolates between the values using a cubic curve ("smooth step"):
	 * <code>result = (pos / maxPos)^2 * (3 - 2 * (pos / maxPos))</code>.
	 * 
	 * @see {@link Interpolator#interpolate(float, float)}
	 */
	public final float interpolate(float pos, float maxPos) {
		final float relPos = pos / maxPos;
		return relPos * relPos * (3.0f - 2.0f * relPos);
	}

	public final void parseFrom(String params) {
	}
}
